<h2>Getting Started</h2>
	
<p>
<span class="title">I. Create Actions</span>
<div class="def">
	<p><b><a id="action">Action</a></b> presents some atomic logic operation (like function in interface) 
	and contains input and output data. 
</div>
<p>For example we have <tt>Doc</tt> class for presents some document object. 
So in our app we can create actions like 
<tt>CreateDoc</tt>, 
<tt>RenameDoc</tt>, 
<tt>DeleteDoc</tt> for working with documents. 
And <tt>CreateDoc</tt> for example has input <tt>String</tt> (name of the doc) and output <tt>Doc</tt> (created object):

<pre class="brush: java;">
	import com.gf.Action;

	public class CreateDoc extends Action&lt;String, Doc&gt;{
	
		public CreateDoc(String name) {
			super(name);
		}
		
	}</pre>


<p class="more-top">
<span class="title">II. Create Handlers</span>
<div class="def">
	<p><b><a id="handler">Handler</a></b> implements logic of the action (like interface function's implementation). 
	It uses Action object for taking input data and setting output data.
</div>
<p>Note: Handler must contains <tt>@Mapping</tt> annotation.
<p>Let's implement <tt>CreateDoc</tt> logic:
<pre class="brush: java;">
import com.gf.Handler;
import com.gf.annotation.Mapping;

import foo.Storage;

@Mapping(CreateDoc.class)
public class CreateDocHandler extends Handler&lt;CreateDoc&gt;{

	@Inject
	Storage storage;
	
	public void invoke(CreateDoc action) throws Exception {
	
		String name = action.getInput();
		Doc created = storage.createNewDoc(name);
		
		action.setOutput(created);
	}
}</pre>

	
<p class="more-top">
<span class="title">III. Connect actions with handlers by Engine</span>
<div class="def">
	<p><b><a id="engine">Engine</a></b> is the central class of <gff>. 
	Use it for create object with Action-Handler API.
</div>
<pre class="brush: java;">
import com.gf.core.Engine;

Engine engine = new Engine();
engine.addToContext(storage);
engine.putHandler(CreateDocHandler.class);

Doc result = engine.invoke(new CreateDoc("some name"));</pre>

<p class="more-top">
<span class="title">IV. Use class scanner</span>
<br>If you have a set of handlers, interceptors and filters you can add all of them by package scanning:
<pre class="brush: java;">
import com.gf.core.Engine;

Engine engine = new Engine();

//put all valid handlers, interceptors and filters
engine.scanAndPut("foo.bar");

Doc result = engine.invoke(new CreateDoc("some name"));</pre>


<p class="more-top">
<span class="title">V. Create understandable interface</span>
<br>Use understandable name of your API not just the universal <tt>Engine</tt>.
For this reason you can extend <tt>ActionService</tt> interface: 
<pre class="brush: java;">
import com.gf.service.ActionService;

public interface DocService extends ActionService { }


//example of service using
DocService service = getService();
Doc result = service.invoke(new CreateDoc("some name"));</pre>

<p>And create implementation with <tt>Engine</tt> inside:
<pre class="brush: java;">
import com.gf.core.Engine;
import foo.Storage;

public class DocServiceImpl implements DocService {

	private Engine engine;

	public DocServiceImpl() {
	
		Storage storage = new Storage();
		
		engine = new Engine();
		engine.addToContext(storage);
		engine.putHandler(CreateDocHandler.class);
	}
	
	
	public &lt;I, O&gt; O invoke(Action&lt;I, O&gt; action) {
		return engine.invoke(action);
	}
	
	public &lt;I, O&gt; O invokeUnwrap(Action&lt;I, O&gt; action) throws Exception {
		return engine.invokeUnwrap(action);
	}

}</pre>


<p class="more-top">
<span class="title"><a id="aspects">VI. Add aspects things</a></span>
<br>In next step you can use <tt>Filters</tt> and <tt>Interveptors</tt> for aspects (like validation or security).
<p>Example of security filter:
<pre class="brush: java;">
import com.gf.Filter;

public class SecurityFilter extends Filter {
	
	@Override
	public void invoke(Action&lt;?, ?&gt; action, FilterChain chain) 
			throws Exception {
		
		boolean isPermitted = checkUserPermissions();
		
		if( ! isPermitted) throw new SecutiryException();
		else chain.doNext();
		
	}

}</pre>

<p>And example of validation interceptor:
<pre class="brush: java;">
import com.gf.Interceptor;
import com.gf.annotation.Mapping;

@Mapping(CreateDoc.class)
public class CheckNameInterceptor extends Interceptor&lt;CreateDoc&gt;{

	@Override
	public void invoke(CreateDoc action, InterceptorChain chain)
			throws Exception {
		
		String name = action.input();
		if(name == null 
				|| name.length() == 0)
			throw new InvalidNameException();
		
		chain.doNext();
		
	}

}</pre>